<template>
	<div>
		<div class="graybg"></div>
		<div class="header header_bg">
			<div class="header_left">
				<i onclick="javascript:history.back(-1)" class="iconfont baiColor">&#xe612;</i>
			</div>
			<div class="header_center">
				<span class="baiColor">修改支付密码</span>
			</div>
		</div>

		<div class="center">
			<form action="" method="post" style="padding-top: 52px;">
				<input type="password" name="passold" maxlength="6" placeholder="原支付密码" v-model="passold" value="" />
			
				<input type="password" name="pass" maxlength="6" placeholder="新支付密码" v-model="pass" value="" />
				
				<input type="password" name="surepass" maxlength="6" placeholder="确认新支付密码" v-model="surepass" value="" />
			</form>
			<button @click="updatepass">确定</button>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				passold: '', //原支付密码
				pass: '', //	新支付密码
				surepass: '', //确认新支付密码
			}
		},
		mounted() {
			//判断是否设置过支付密码
//	      	var params = new URLSearchParams();
//	      	var info = window.localStorage.data;
//	      	params.append('token', info);	//客户秘钥（信息）
//				var arr = ['u_alipay_pwd']
//				params.append('arr', arr);
//				this.$axios({
//					url: "http://192.168.1.186/touzi/Home/Config/getUserField",
//					method: "POST",
//					data: params
//				}).then((res) => {
//					console.log(res)
//				}).catch((err) => {
//					console.log(err)
//				})

		},
		methods: {
			updatepass: function() {
				//如果两次密码输的一致
				if(this.pass == this.surepass){
					var params = new URLSearchParams();
					var info = window.localStorage.data;
					params.append('token', info); //客户秘钥（信息）
					params.append('password', this.passold); //原支付密码
					
					params.append('pwd', this.surepass); //确认支付密码
					params.append('type', 2);
					this.$axios({
						url: "Home/Money/alipay_pwd",
						method: "POST",
						data: params
					}).then((res) => {
						if(res.data == 3) {
							alert('原密码输入错误')
						}
					}).catch(function(err) {
						console.log(err)
					})
				}else{
					alert('两次支付密码输入不一致，请重新输入')
					location.reload();
				}
				

			}
		},
	}
</script>

<style scoped="scoped">
	@import "../css/public.css";
	.center {
		width: 95%;
		margin: 0 auto;
	}
	
	.center form {
		width: 100%;
	}
	
	.center form input {
		padding-left: 10px;
		display: block;
		background: #FFFFFF;
		width: 97%;
		margin: 10px 0;
		height: 40px;
		line-height: 38px;
	}
	
	input::-webkit-input-placeholder {
		color: #999;
		font-size: 15px;
	}
	
	.center button {
		background: #F3961F;
		width: 100%;
		height: 45px;
		border-radius: 10px;
		font-size: 18px;
		color: #FCFCFC;
		margin-top: 128px;
	}
</style>